package Utils;

import java.util.Scanner;

//电路实验误差计算
public class CountWuCha {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            try {
                System.out.println("请输入计算值：");
                double jiSuanZhi = scanner.nextDouble();
                System.out.println("请输入测量值：");
                double ceLiangZhi = scanner.nextDouble();
                countWuCha(jiSuanZhi, ceLiangZhi);
                System.out.println("继续计算请输入1，停止输入0");
            } catch (Exception e) {
                System.out.println("？");
            }
            int continueOrStop = 0;
            try {
                continueOrStop = scanner.nextInt();
            } catch (Exception e) {
                System.out.println("别输入一些奇怪的东西");
            }
            if (continueOrStop == 0) {
                break;
            }
        }
    }

    public static void countWuCha(double jiSuanZhi, double ceLiangZhi) {
        double result = (ceLiangZhi - jiSuanZhi) / jiSuanZhi;
        System.out.println("相对误差为：" + result * 100 + "%");
    }
}
